//
//  AppViewController.m
//  YinYueBoFang_Forever
//
//  Created by lanou3g on 15/11/8.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "AppViewController.h"
#import "AppView.h"
#import "RootTableViewController.h"
@interface AppViewController ()<UIScrollViewDelegate>
@property(nonatomic,strong)AppView *av;
@property(nonatomic,strong)UIImageView *imv;
@property(nonatomic,strong)NSTimer *timer;





@end

@implementation AppViewController

-(void)loadView
{
    self.av = [[AppView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.view = self.av;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self makeScroView];
    
    

    //        NSLog(@"%ld",a);

    self.timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
}

-(void)timerAction
{
    NSInteger a = self.av.scrollView.contentOffset.x/375;
//    NSLog(@"%lf",self.av.scrollView.contentOffset.x);
//    NSLog(@"%lf",self.av.scrollView.contentOffset.x/375.0);
    if (a == 2) {
        
        RootTableViewController *rtVC = [[RootTableViewController alloc] init];
        [self showViewController:rtVC sender:nil];
    }

    
}

-(void)makeScroView
{
    CGFloat w = CGRectGetWidth(self.av.scrollView.frame);
    
    CGFloat h = CGRectGetHeight(self.av.scrollView.frame);
    
    
    
    self.av.scrollView.contentSize = CGSizeMake(w * 3, h);
    for (int i = 1; i < 4; i++) {
        UIImage * image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",i]];
        
        self.av.scrollView.delegate = self;
        UIImageView * imv = [[UIImageView alloc] initWithImage:image];
        imv.frame = CGRectMake(w*(i-1), 0, w, h);
        [self.av.scrollView addSubview:imv];
        self.av.scrollView.pagingEnabled = YES;

 
    }

    
}

-(void)tapAction
{
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
